use ${nc_clean_data}/combined_full_wide if dbm==11 | dbm==12 | dbm==1 | dbm==2 , clear

***********************************
**********  TABLES  ***************
***********************************

***********Table 7: Effect of Cash Transfer Eligibility on Student Outcome Index (North Carolina)************
regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{g_/entry_grade\} @{/sample\} , @{se_/se\}", ///
        runs{ outcome[  indexf_testgradsusp ] ///
				 sample[ r_frl ] ///
				 cutyrs[ 1993_1998 ] ///
				 covars[ x_cyr x_cyr_dow x_demog_nosyr2 ] ///
				 entry_grade[ ming5 ] ///
				 se[clust_z] ///
				 donut[8] ///
				 wdays[20] } ///
         coeffs{bcut[1.belowcut]} ///
         stats{mean[r(mean), summ /outcome\ if e(sample) & belowcut==1 ] ///
					  r2[e(r2), ] } ///
          dataout{${results}/final_t7} fileout{${results}/final} sheetout{t7}

***********Table 8: Effect of Cash Transfer Eligibility on Individual Student Outcomes (North Carolina)************
regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{g_/entry_grade\} @{/sample\} , @{se_/se\}", ///
         runs{ outcome[  index_test  ever_susp ever_exitgrad ] ///
				 sample[ r_frl ] ///
				 cutyrs[ 1993_1998 ] ///
				 covars[ x_cyr x_cyr_dow x_demog_nosyr2 ] ///
				 entry_grade[ ming5 ] ///
				 se[clust_z] ///
				 donut[8] ///
				 wdays[20] } ///
        coeffs{bcut[1.belowcut]} ///
        stats{mean[r(mean), summ /outcome\ if e(sample) & belowcut==1 ] ///
					  r2[e(r2), ] } ///
        dataout{${results}/final_t8} fileout{${results}/final} sheetout{t8}

***********Table A3: Balance on Baseline Student Demographic Characteristics (North Carolina)************
regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1) @{g_/grade\} @{/sample\} @{d_/donut\} & /restrict\==1, @{se_/se\}", ///
					 runs{ outcome[ ever_bl ever_wh ever_hi ever_frl ever_lep ever_sm ] ///
					 sample[ @{s_/outcome\} ] ///
					 cutyrs[ 1993_1998 ] ///
					 covars[ x_cyr ] ///
					 restrict[ none ] ///
					 grade[ ming5 ] ///
					 se[clust_z] ///
					 donut[8] ///
					 wdays[20] } ///
					 coeffs{bcut[1.belowcut]} ///
					 stats{mean[r(mean), summ /outcome\ if e(sample) & belowcut==1 ] ///
						  r2[e(r2), summ cutyr if e(sample)] } ///
					dataout{${results}/final_ta3} fileout{${results}/final} sheetout{ta3}

***********Table A10: Effect of Cash Transfer Eligibility on Student Outcome Index: Robustness to Inclusion of Various Fixed Effects************

destring schlcode3, force replace
destring lea3, force replace

regrunner "reghdfe /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{g_/entry_grade\} @{/sample\} , absorb(@{/fe\}) ", ///
           runs{ outcome[ indexf_testgradsusp ] ///
						 sample[r_frl ] ///
						 cutyrs[ 1993_1998 ] ///
						 covars[ x_none ] ///
						 entry_grade[ ming5 ] ///
						 fe[fe_base fe_l  fe_l_cyr fe_s fe_s_cyr ] ///
						 se[clust_z] ///
						 donut[8] ///
						 wdays[20] } ///
             coeffs{bcut[1.belowcut]} ///
             stats{mean[r(mean), summ /outcome\ if e(sample)] ///
					  	r2[e(r2), ] } ///
             dataout{${results}/final_ta10} fileout{${results}/final} sheetout{ta10}

***********Table A11: Effect of Cash Transfer Eligibility on Student Outcome Index: Robustness to Alternative Index Construction************
regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{g_/entry_grade\} @{/sample\} , @{se_/se\}", ///
				 	runs{ outcome[  indexf_testgradsusp  indexm_testgradsusp indexnm_testgradsusp ] ///
					sample[ r_frl ] ///
					cutyrs[ 1993_1998 ] ///
					covars[ x_cyr x_cyr_dow x_demog_nosyr2 ] ///
					entry_grade[ ming5 ] ///
					se[clust_z] ///
					donut[8] ///
					wdays[20] } ///
				 coeffs{bcut[1.belowcut]} ///
				 stats{mean[r(mean), summ /outcome\ if e(sample) & belowcut==1 ] ///
						 r2[e(r2), ] } ///
				 dataout{${results}/final_ta11} fileout{${results}/final} sheetout{ta11}

***********Table A12: Heterogeneity of Effect of Cash Transfer Eligibility on Student Outcome Index by Student Demographics************
regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1) @{g_/grade\} @{/sample\} @{d_/donut\} @{/restrict\}, @{se_/se\}", ///
					 runs{ outcome[ indexf_testgradsusp ] ///
					 sample[ r_frl ] ///
					 cutyrs[ 1993_1998 ] ///
					 covars[ x_cyr ] ///
					 restrict[ r_wh r_bl r_hi r_lep r_sm r_sf ] ///
					 grade[ ming5 ] ///
					 se[clust_z] ///
					 donut[8] ///
					 wdays[20] } ///
					 coeffs{bcut[1.belowcut]} ///
					 stats{mean[r(mean), summ /outcome\ if e(sample) & belowcut==1 ] ///
						  r2[e(r2), summ cutyr if e(sample)] } ///
					 dataout{${results}/final_ta12} fileout{${results}/final} sheetout{ta12} silent

***********Table A13: Effect of Cash Transfer Eligibility on Adolescent Outcomes ************
 regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{g_/entry_grade\} @{/sample\} , @{se_/se\}", ///
	        	runs{ outcome[  ever_hssusp ever_exitgrad a_sds e_sds ] ///
	 				 sample[ r_frl  ] ///
	 				 cutyrs[ 1993_1998 ] ///
	 				 covars[ x_cyr x_cyr_dow x_demog_nosyr2 ] ///
	 				 entry_grade[ ming5 ] ///
	 				 se[clust_z] ///
	 				 donut[8] ///
	 				 wdays[20] } ///
            coeffs{bcut[1.belowcut]} ///
            stats{mean[r(mean), summ /outcome\ if e(sample) & belowcut==1 ] ///
 					  r2[e(r2), ] } ///
            dataout{${results}/final_ta13} fileout{${results}/final} sheetout{ta13}


***********************************
********* Results for Figures *****
***********************************

***********Figure A15: Student Outcome Index RD Estimates by Donut Size (North Carolina) ************
regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{/sample\} @{g_/grade\} & /restrict\==1, @{se_/se\}", ///
					 runs{ outcome[ indexf_testgradsusp ] ///
					 sample[ r_frl ] ///
					 cutyrs[ 1993_1998 ] ///
					 covars[ x_cyr ] /// //x_cyr @{x_/outcome\}
					 restrict[ none ] ///
					 grade[ ming5  ] ///
					 se[clust_z] ///
					 donut[0 1 2 4 6 8 10] ///
					 wdays[20] } ///
					 coeffs{bcut[1.belowcut]} ///
					 stats{mean[r(mean), summ /outcome\ if e(sample)] ///
						  r2[e(r2), ] } ///
					 dataout{${results}/final_fa15} fileout{${results}/final} sheetout{fa15}

***********Figure A16: Student Outcome Index RD Estimates by Bandwidth (North Carolina) ************
regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{/sample\} @{g_/grade\} & /restrict\==1, @{se_/se\}", ///
					 runs{ outcome[ indexf_testgradsusp ] ///
					 sample[ r_frl ] ///
					 cutyrs[ 1993_1998 ] ///
					 covars[ x_cyr ] ///
					 restrict[ none ] ///
					 grade[ ming5 ] ///
					 se[clust_z] ///
					 donut[8] ///
					 wdays[10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ] } ///
					 coeffs{bcut[1.belowcut]} ///
					 stats{mean[r(mean), summ /outcome\ if e(sample)] ///
						  r2[e(r2), ] } ///
					 dataout{${results}/final_fa16} fileout{${results}/final} sheetout{fa16}

***********Figure A20: Effect of Cash Transfer Eligibility on Student Test Score Index Across Grades (North Carolina) ************
 regrunner "reg /outcome\ i.belowcut##c.z @{/covars\} if @{cyrs_/cutyrs\}  &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1) @{/sample\}@{g_/grade\} & /restrict\==1, @{se_/se\}", ///
 				 runs{ outcome[ mr_sds3 mr_sds4 mr_sds5 mr_sds6 mr_sds7 mr_sds8 ae_sds] ///
 				 sample[r_frl ] ///
 				 cutyrs[ 1993_1998 ] ///
 				 covars[ x_cyr  ] /// //x_cyr @{x_/outcome\}
 				 restrict[ none ] ///
 				 grade[ ming5 ] ///
 				 se[clust_z] ///
 				 donut[8] ///
 				 wdays[20] } ///
 				 coeffs{bcut[1.belowcut]} ///
 				 stats{mean[r(mean), summ /outcome\ if e(sample) & belowcut==1 ] ///
 					  r2[e(r2), ] } ///
 					dataout{${results}/final_fa20} fileout{${results}/final} sheetout{fa20}
